﻿using System.Collections;
using System.Collections.Generic;
using Unity.Entities;
using UnityEngine;

public class HelloWorldSample : MonoBehaviour
{
    public GameObject prb_cube;
    // Use this for initialization
    void Start()
    {
        CreateCubes(1000);
    }

    void CreateCubes(int count)
    {
        var root = new GameObject();
        root.name = "Root";
        for (int i = 0; i < count; ++i)
        {
            var originalCube = GameObject.Instantiate(prb_cube) as GameObject;
            originalCube.transform.parent = root.transform;
            originalCube.transform.position = UnityEngine.Random.insideUnitSphere * (count / 100);
            originalCube.gameObject.AddComponent<Test>();
            originalCube.gameObject.AddComponent<HelloWorldComponentData>();
            //需要给GameObject添加GameObjectEntity组件，才能让原先的GameObject被EntityManger识别为Enity。
            originalCube.AddComponent<GameObjectEntity>();
        }
    }
}
